<template>
	<view class="addcard">
		<view class="box">
			<view class="item">
				<view class="name">
					支付密码
				</view>
				<u--input type="password" placeholder="输入支付密码" border="none" v-model="pass"></u--input>
			</view>
		</view>
		<view class="button_box">
			<view @click="setpass" class="button act">
				确定
			</view>
		</view>
	</view>
</template>

<script>
	import {
		setpass
	} from '@/api/mine'
	export default {
		data() {
			return {
				pass: ''
			}
		},
		onShow() {

		},
		methods: {
			setpass() {
				if (!this.pass) {
					uni.showToast({
						icon: 'none',
						title: '请输入支付密码!'
					})
					return
				}
				var reg = new RegExp(/^\d{6}$/);
				if (!(reg.test(this.pass))) {
					uni.showToast({
						icon: 'none',
						title: '支付密码必须为6位数字!'
					})
					return
				}
				let data = {
					password: this.pass
				}
				setpass(data).then(res => {
					if (res.success == 1) {
						uni.showToast({
							icon: 'none',
							title: '设置成功!'
						})
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					} else {
						uni.showToast({
							icon: 'none',
							title: res.message
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #e7e9ec;
	}

	.addcard {
		padding: 50rpx 0;
	}

	.box {
		padding: 30rpx;
		background: #FFFFFF;
		border-radius: 15px 15px 0px 0px;
		margin-bottom: 100rpx;

		.item {
			display: flex;
			align-items: center;
			padding: 25rpx 10rpx;
			// border-bottom: 2rpx solid rgba(151, 151, 151, 0.2);

			.name {
				width: 25%;
				color: rgba(0, 0, 0, 0.9);
				font-size: 34rpx;
			}

			.right {
				width: 73%;
			}
		}

		.nobor {
			border: none;
		}
	}

	.button_box {
		text-align: center;
		padding-bottom: 80rpx;

		.button {
			display: inline-block;
			background: #FFBE53;
			border-radius: 20px;
			padding: 10rpx 80rpx;
		}

		.act {
			background: #FFBE53;
			border-radius: 40rpx;
			color: #FFFDEF;
		}

		.noact {
			border-radius: 40rpx;
			border: 2rpx solid #A6A6A6;
			color: #A6A6A6;
		}
	}
</style>
